package day20171009;
import java.util.Scanner;
public class DemoString {
    public static void main(String[] args) {
        System.out.println("请输入一个字符串.");
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        char[] ch = str.toCharArray();
        count use = new count();
        use.count(ch);
    }
}
class count {
    int digital,character,blank,other;

    public void count(char[] arr) {
        for(int i = 0; i < arr.length; i ++) {
            if(arr[i] >= '0' && arr[i] <= '9') {
                digital ++;
            }else if((arr[i] >= 'a' && arr[i] <= 'z') || (arr[i] >= 'A' && arr[i] <= 'z')) {
                character ++;
            }else if(arr[i] == ' ') {
                blank ++;
            }else {
                other ++;
            }
        }
        System.out.println("数字个数：" + digital);
        System.out.println("英文字母个数：" + character);
        System.out.println("空格个数：" + blank);
        System.out.println("其他字符个数：" + other);
    }
}
